const { Apis } = require('./apiModel');
const { Menus } = require('./menuModel');
const { Roles } = require('./roleModel');
const { AdminUser } = require('../../user/models/userModel')

//设置菜单与api多对多关联
Menus.belongsToMany(Apis, { through: "menuLinkApis" })
Apis.belongsToMany(Menus, { through: "menuLinkApis" })

// 设置角色与菜单多对多关联
Menus.belongsToMany(Roles, { through: "roleLinkMenus" })
Roles.belongsToMany(Menus, { through: "roleLinkMenus" })

// 设置用户与角色多对多关联
AdminUser.belongsToMany(Roles, { through: "userLinkRoles" })
Roles.belongsToMany(AdminUser, { through: "userLinkRoles" })

module.exports = {
    Apis,
    Menus,
    Roles
}